import request from "@/utils/request";

const farmerInformationAPI = {
  // 农户列表
  getFarmerList(queryParams: seachQuery) {
    let query = encodeURIComponent(JSON.stringify({ ...queryParams }));
    return request<any, any>({
      url: `/core/tBdFarmer/getFarmerList?object=${query}`,
      method: "get",
    });
  },

  /**
   * 新增或更新农户信息
   *
   * @param data 农户表单
   */
  saveOrUpdateFarmer(data: FarmerInfo) {
    return request({
      url: `/core/tBdFarmer/saveOrUpdateFarmer`,
      method: "post",
      data: data,
    });
  },
  /**
   * 删除农户
   *
   * @param id
   */
  delFarmer(id: any) {
    return request({
      url: `/core/tBdFarmer/delFarmer`,
      method: "post",
      data: id,
    });
  },
};
export default farmerInformationAPI;
// 查询参数
export interface seachQuery extends PageQuery {
  farmerName?: string;
  farmerType?: string;
}

export interface FarmerInfo {
  id?: string;
  farmerName?: string; //农户名称
  farmerType?: string; //农户类型
  contact?: string; //联系方式
  location?: string; //地理位置
  plantArea?: number; //种植面积(亩)
  annualQty?: number; //年产量(吨)
  crops?: string; //农作物 用,号隔开
  remark?: string; //备注
}
